package com.blank.shop.hystrix.consumer;

import com.blank.shop.hystrix.ShopHystrixApplication;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Profile;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

/**
 * <br/>Date 2021/8/31
 * <br/>Time 15:08:27
 *
 * @author _blank
 */
@Profile({ShopHystrixApplication.SERVER_CONSUMER})
@Service
public class HystrixConsumerFallbackServiceImpl implements HystrixConsumerService, InitializingBean {

    @Value("${server.port}")
    private Integer serverPort;
    private ResponseEntity<String> ok;

    @Override
    public void afterPropertiesSet() throws Exception {
        this.ok = ResponseEntity.ok("服务提供方已无响应，执行当前服务【" + this.serverPort + "】的兜底方案！");
    }

    @Override
    public ResponseEntity<String> simulationNormal() {
        return this.ok;
    }

    @Override
    public ResponseEntity<String> simulationTimeOut() {
        return this.ok;
    }

}
